<?php
require('../../setting.php');
$toper = $_GET['to'];
$subject = $_GET['subject'];
$message = $_GET['message'];
use PHPMailer\PHPMailer\PHPMailer;
use PHPMailer\PHPMailer\Exception;
require '../../phpmailer/src/Exception.php';
require '../../phpmailer/src/PHPMailer.php';
require '../../phpmailer/src/SMTP.php';
$mail = new PHPMailer(true);                              
try {
    $mail->CharSet ="UTF-8";                     
    $mail->SMTPDebug = 0;                       
    $mail->isSMTP();                             
    $mail->Host = $setting_mail_array['smtp_host'];              
    $mail->SMTPAuth = true;                      
    $mail->Username = $setting_mail_array['smtp_user'];   
    $mail->Password = $setting_mail_array['smtp_pass'];           
    $mail->SMTPSecure = $setting_mail_array['smtp_secure'];                    
    $mail->Port = $setting_mail_array['smtp_port'];                         
    $mail->setFrom($setting_mail_array['smtp_user'], '管理员');  
    $mail->addAddress($toper, '亲爱的用户');  
    $mail->isHTML(true);                                 
    $mail->Subject = $subject . time();
    $mail->Body    = "<h1>$message</h1>" . date('Y-m-d H:i:s');
    $mail->AltBody = "$message";
    $mail->send();
    echo json_encode(array('code'=>200));
} catch (Exception $e) {
    echo json_encode(array('code'=>400));
}